<template>
  <div class="container" @click="handleGallaryClick">
    <swiper class="swiper" :options="swiperOption">
      <!-- slides -->
      <swiper-slide v-for="(imgUrl,index) in imgs" :key="index">
        <img class="gallary-img" :src="imgUrl" />
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: "CommonGallary",
  props: {
    imgs: {
      type: Array,
      default() {
        return [
          "https://img1.qunarzz.com/vs_ceph_vs_tts/a6540f6c-a7ed-43a6-9ff0-188b7f09a1f8.jpg_r_640x420x90_5e8e2c47.jpg",
          "https://img1.qunarzz.com/vs_ceph_vs_tts/a6540f6c-a7ed-43a6-9ff0-188b7f09a1f8.jpg_r_640x420x90_5e8e2c47.jpg"
        ];
      }
    }
  },
  data: function() {
    return {
      swiperOption: {
        pagination: ".swiper-pagination",
        paginationType: "fraction",
        observeParents: true,
        observer: true
      }
    };
  },
  methods: {
    handleGallaryClick() {
      this.$emit("close-gallary");
    }
  }
};
</script>


<style lang="stylus" scoped>
.container {
  position: fixed;
  display: flex;
  flex-direction: column;
  justify-content: center;
  z-index: 1;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background-color: #000;

  .swiper {
    overflow: hidden;
    height: 0;
    width: 100%;
    padding-bottom: 100%;

    .gallary-img {
      width: 100%;
    }

    .swiper-pagination {
      color: #fff;
    }
  }
}
</style>